
var V=new Vue({
    el:'#main',
    data:()=>({
        datalist:[],
        page:1,
        pageSize:10,
        listStatus:9,
        title:'',
        lang:'',
        searchText:'',
        searchContent:''
    }),
    methods:{
        getdata(){  //获取数据方法
            var data={
                page:this.page,
                limit:this.pageSize,
                lang:this.lang,
                searchText:$('#searchText').val(),
                searchContent:$('#searchContent').val()
            }
            // console.log(data)
            $.ajax({
                url:'/admin/multilanguage/list',
                type:'post',
                data,
                success:(data)=>{
                    data = JSON.parse(data)
                    this.datalist = data.list
                    this.title = data.title
                    if(data.size / 10>1){
                        $('#pagination').show()
                        this.Resetnav(data.page-0,data.size)
                    }else{
                        $('#pagination').hide()
                    }
                }
            })
        },
        changelang(lang){
            this.lang=lang
        },
        Resetnav(pageCurrent, pageSum) {
            //数据总条数
            var myPageCount = pageSum;
            //一页显示多少条
            var myPageSize = this.pageSize;
            //总页数
            var countindex = myPageCount % myPageSize > 0 ? (myPageCount / myPageSize) + 1 : (myPageCount / myPageSize);
            $.jqPaginator('#pagination', {
                totalPages: parseInt(countindex),
                //最多显示多少页
                visiblePages: 5,
                //默认显示第几页
                currentPage: pageCurrent,
                first: '<li class="first"><a href="javascript:;">'+langcon.page_home+'</a></li>',
                prev: '<li class="prev"><a href="javascript:;"><i class="arrow arrow2"></i>'+langcon.previous_page+'</a></li>',
                next: '<li class="next"><a href="javascript:;">'+langcon.next_page+'<i class="arrow arrow3"></i></a></li>',
                last: '<li class="last"><a href="javascript:;">'+langcon.last_page+'</a></li>',
                page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
                all:'<li class="page"><a href="javascript:;">'+parseInt(countindex)+' / '+this.page+'PG , '+this.pageSize+' /PG</a></li>',
                onPageChange:(num, type)=>{
                    if (type == "change") {
                        console.log(num)
                        this.page=num
                    }
                }
            });
        },
        requestDelete(abbreviation){
            $.ajax({
                url:'/admin/multilanguage/requestDelete',
                data: {abbreviation:abbreviation},
                type:'post',
                success:(data)=>{
                    data = JSON.parse(data)    
                    change_mes_type('.alert',data.status)
                    if(data.status==1){
                        $('.alert').show()
                        $('.alert p').html('*'+data.msg+'<br>')
                        this.getdata()
                    }else{
                        $('.alert').show()
                        $('.alert p').html('*'+data.msg+'<br>')
                    }
                }
            })
        },
        getSearchText(){
            this.getdata()
        },
    },
    mounted(){
        this.getdata()
        $('#multilanguage_editModal').on('hidden.bs.modal',(e)=>{
            this.getdata()
          })
    },
    watch:{
        page:function(){
          this.getdata()  
        },
        lang:function(){
            this.getdata()
        }
    }
})
function list_normal(){
    $(".option-pulloff").each(function(){
        $(this).show();
    });

    $(".option-del").each(function(){
        $(this).hide();
    });

    $(".option-recover").each(function(){
        $(this).hide();
    });

    $(".option-clear").each(function(){
        $(this).hide();
    });
}


$(document).ready(function() {
    
    //设置modal垂直居中,移动
    // modalSetting(".modal"); 

    $("#list-pulloff").click(function(){
        $(".option-pulloff").each(function(){
            $(this).hide();
        });

        $(".option-del").each(function(){
            $(this).show();
        });

        $(".option-recover").each(function(){
            $(this).hide();
        });

        $(".option-clear").each(function(){
            $(this).hide();
        });

    });

    $("#list-del").click(function(){
        $(".option-pulloff").each(function(){
            $(this).hide();
        });

        $(".option-del").each(function(){
            $(this).hide();
        });

        $(".option-recover").each(function(){
            $(this).show();
        });
        
        $(".option-clear").each(function(){
            $(this).show();
        });
    });

});